<?php							
		class CConfiguration extends database
		{
			var $table = 'cdb_configuration';
			
			public function CConfigurationValue($col)
			{
				if(is_int($col))
				{
					$sql = "Select value from {$this->table} where id ='{$col}'";
				}
				else
				{
					$sql = "Select value from {$this->table} where name ='{$col}'";
				}
				
				$this->setQuery($sql);
				$this->query();
				
				$arrTemp =  $this->loadAllRow();
				
				
				$numOfRow = mysql_affected_rows();
				if($numOfRow>0)
					return $arrTemp[0]['value']; 
				else
					return -1;
				
			}
			
			public function CConfigurationStatus($col)
			{
				if(is_int($col))
				{
					$sql = "Select value from {$this->table} where id ='{$col}'";
				}
				else
				{
					$sql = "Select value from {$this->table} where name ='{$col}'";
				}
				
				$this->setQuery($sql);
				$this->query();
				
				$arrTemp =  $this->loadAllRow();
				
				
				$numOfRow = mysql_affected_rows();
				if($numOfRow>0)
					return $arrTemp[0]['status']; 
				else
					return -1;				
			}
			
			
			
			
			
			public function CConfigurationList()
			{
				$sql="select * from {$this->table}";
				$this->setQuery($sql);
				$this->query();

				
				$arrTemp =  $this->loadAllRow();
				
				
				$numOfRow = mysql_affected_rows();
				if($numOfRow>0)
					return $arrTemp; 
				else
					return -1;
			}
			
			public function CConfigurationDetail ($id)
			{
				$sql="select * from $this->table where id='{$id} '";
				$this->setQuery($sql);
				$this->query();
				$arr=$this->loadAllRow();
				
				$numOfRow = mysql_affected_rows();
				if($numOfRow>0)
					return $arr[0];
				else
					return -1;
			}
				
			
			
			public function CConfigurationAdd ($name,$value,$status)
			{
				$sql = "INSERT INTO {$this->table} (`name`,`value`,`status`)
	VALUES ('{$name}','{$value}','{$status}');";
				
				$this->setQuery($sql);
				$this->query();
				
				return mysql_affected_rows();									
			}
			
			public function CConfigurationUpdateValue($id,$value)
			{
				$sql = "update $this->table set value = $value where id = $id ";
				$this->setQuery($sql);
				$this->query();
				return mysql_affected_rows();
			}
			
			public function CConfigurationUpdate ($id,$name,$content,$status)
			{
				$sql = "update $this->table set name ='{$name}',value ='{$value}',status ='{$status}' where id = '{$id}' ";
			
				$this->setQuery($sql);
				$this->query();
				return mysql_affected_rows();
			}
			
			public function CConfigurationDelete($id)
			{
				$sql="Delete from  $this->table where id= $id ";
				$this->setQuery($sql);
				$this->query();
				return mysql_affected_rows();
			}			
		}	
	
	
	?>